<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=s, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    const len = nums.length;
    let l = r = sum = 0;
    res = len + 1;
    while (r < len) {
      sum += nums[r++];
      while (sum >= target) {
        res = res < r - l ? res : r - l;
        sum -= nums[l++];
      }
    }
    return res > len ? 0 : res;
  </script>
</body>
</html>